import asyncio, aiofiles

async def write_demo():
    async with aiofiles.open("text.txt","w",encoding="utf-8") as fp:
        await fp.write("hello world")
        print("数据写入成功")

async def read_demo():
    async with aiofiles.open("text.txt","r",encoding="utf-8") as fp:
        content = await fp.read()
        print(content)

if __name__ == "__main__":
    asyncio.run(write_demo())
    asyncio.run(read_demo())